import React, { Component } from 'react'

export default class ForceCom extends Component {
  //声明状态
  state = {
    count: 1
  }

  render() {
    return (
      <div>
        <h2>{this.state.count}</h2>
        <hr />
        <button onClick={() => {
          //调用 setState
          // this.setState({
          //   count: this.state.count + 1
          // })
          //更新状态
          this.state.count = this.state.count + 1;
          //调用 forceUpdate
          this.forceUpdate();
        }}>增加</button>
      </div>
    )
  }
}
